import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class MySQLDriver {

	public static void main(String[] args) {
		String driverName = "com.mysql.jdbc.Driver";   //加载JDBC驱动 
		String url = "jdbc:mysql://192.168.1.194:3306/bankzhtest?useUnicode=true&characterEncoding=UTF-8";
		String username = "bankzhtest";
		String password = "bankzhtest";
		
		Connection conn = null;
		
		try{
			Class.forName(driverName);
			conn = DriverManager.getConnection(url, username, password);
			System.out.println("数据库连接成功");
		}catch(SQLException e){
			System.out.println("数据库连接失败！");   
			e.printStackTrace();
		} catch (ClassNotFoundException e){
			e.printStackTrace();
		}finally{
			try {
				if(conn!= null) conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
}
